package com.ruoyi.house_sale.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.house_sale.domain.Examresult;
import com.ruoyi.house_sale.service.IExamresultService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 答题卡Controller
 * 
 * @author ruoyi
 * @date 2022-04-16
 */
@RestController
@RequestMapping("/house_sale/examresult")
public class ExamresultController extends BaseController
{
    @Autowired
    private IExamresultService examresultService;

    /**
     * 查询答题卡列表
     */
    @PreAuthorize("@ss.hasPermi('house_sale:examresult:list')")
    @GetMapping("/list")
    public TableDataInfo list(Examresult examresult)
    {
        startPage();
        List<Examresult> list = examresultService.selectExamresultList(examresult);
        return getDataTable(list);
    }

    /**
     * 导出答题卡列表
     */
    @PreAuthorize("@ss.hasPermi('house_sale:examresult:export')")
    @Log(title = "答题卡", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Examresult examresult)
    {
        List<Examresult> list = examresultService.selectExamresultList(examresult);
        ExcelUtil<Examresult> util = new ExcelUtil<Examresult>(Examresult.class);
        util.exportExcel(response, list, "答题卡数据");
    }

    /**
     * 获取答题卡详细信息
     */
    @PreAuthorize("@ss.hasPermi('house_sale:examresult:query')")
    @GetMapping(value = "/{resultid}")
    public AjaxResult getInfo(@PathVariable("resultid") Long resultid)
    {
        return AjaxResult.success(examresultService.selectExamresultByResultid(resultid));
    }

    /**
     * 新增答题卡
     */
    @PreAuthorize("@ss.hasPermi('house_sale:examresult:add')")
    @Log(title = "答题卡", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Examresult examresult)
    {
        return toAjax(examresultService.insertExamresult(examresult));
    }

    /**
     * 修改答题卡
     */
    @PreAuthorize("@ss.hasPermi('house_sale:examresult:edit')")
    @Log(title = "答题卡", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Examresult examresult)
    {
        return toAjax(examresultService.updateExamresult(examresult));
    }

    /**
     * 删除答题卡
     */
    @PreAuthorize("@ss.hasPermi('house_sale:examresult:remove')")
    @Log(title = "答题卡", businessType = BusinessType.DELETE)
	@DeleteMapping("/{resultids}")
    public AjaxResult remove(@PathVariable Long[] resultids)
    {
        return toAjax(examresultService.deleteExamresultByResultids(resultids));
    }
}
